<?php /* PROJECTS $Id: do_project_aed.php,v 1.11.10.4 2006/07/25 20:24:13 merlinyoda Exp $ */
$obj = new CProject();
$project_id = intval( dPgetParam( $_GET, 'project_id', 0 ) );
$on_step = dPgetParam( $_GET, 'on_step', 'VALIDATE' );

$results = array('success' => TRUE, 'messages' => array());

$obj->load($project_id);
$warnings = '';
$reasons = $obj->canForceComplete(&$warnings);
if($reasons != '') {
	$results['success'] = FALSE;
	$results['errors'] = $reasons;
}
$results['warnings'] = $warnings;
if ($on_step ==	'VALIDATE') {
	
} else if ($results['success'] && $on_step ==	'DO_COMPLETE') {
	$completed_date = dPgetParam( $_GET, 'completed_date', 0 );
	if (($msg = $obj->doForceComplete()) != '') {
		$results['success'] = FALSE;
		$results['messages'] = $reasons;
	}
}
		
header('Content-Type: text/xml');

$xml = new XmlWriter();
$xml->openMemory();
$xml->startDocument('1.0', 'UTF-8');

$xml->startElement('root');

$xml->writeElement('success', $results['success'] ? 'true' : 'false');
$xml->writeElement('messages', $results['errors'] . $results['warnings']);

$xml->endElement();

echo $xml->outputMemory(true);
?>